package com.example.mountainwalker.controller;

import com.example.mountainwalker.entity.HotelImageInfo;
import com.example.mountainwalker.service.HotelImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/hotel-images")
public class HotelImageController {

    @Autowired
    private HotelImageService hotelImageService;

    // 获取所有酒店图片
    @GetMapping
    public List<HotelImageInfo> getAllHotelImages() {
        return hotelImageService.getAllHotelImages();
    }

    // 根据ID获取酒店图片
    @GetMapping("/{id}")
    public HotelImageInfo getHotelImageById(@PathVariable Integer id) {
        return hotelImageService.getHotelImageById(id);
    }

    // 根据酒店ID获取图片列表
    @GetMapping("/hotel/{hotelId}")
    public List<HotelImageInfo> getImagesByHotelId(@PathVariable Integer hotelId) {
        return hotelImageService.getImagesByHotelId(hotelId);
    }

    // 添加酒店图片
    @PostMapping
    public int addHotelImage(@RequestBody HotelImageInfo hotelImageInfo) {
        return hotelImageService.insertHotelImage(hotelImageInfo);
    }

    // 更新酒店图片
    @PutMapping
    public int updateHotelImage(@RequestBody HotelImageInfo hotelImageInfo) {
        return hotelImageService.updateHotelImage(hotelImageInfo);
    }

    // 删除酒店图片
    @DeleteMapping("/{id}")
    public int deleteHotelImage(@PathVariable Integer id) {
        return hotelImageService.deleteHotelImage(id);
    }
}